﻿using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using HelenServer.BugEngine.Contracts;
using Microsoft.EntityFrameworkCore;

namespace HelenServer.BugEngine.Dal;

[Table("Bug")]
public partial class Bug
{
    [Key]
    public int Id { get; set; }

    public virtual Product Product { get; set; } = null!;

    public virtual Module? Module { get; set; }

    public int? Demand { get; set; }

    [StringLength(128)]
    [Unicode(false)]
    public string Title { get; set; } = null!;

    public string Keywords { get; set; } = string.Empty;

    public int Severity { get; set; }

    public int Priority { get; set; }

    public virtual BugType Type { get; set; } = null!;

    [Column("OS")]
    public virtual Os? Os { get; set; }

    public virtual Browser? Browser { get; set; }

    [Unicode(false)]
    public string Steps { get; set; } = string.Empty;

    public BugStatus Status { get; set; } = BugStatus.Active;

    public bool Confirmed { get; set; } = false;

    public int ActivatedCount { get; set; } = 0;

    [Column(TypeName = "datetime")]
    public DateTime? LastActivatedDate { get; set; }

    [Column("CCList")]
    public int[] Cclist { get; set; } = Array.Empty<int>();

    public int Creator { get; set; }

    [Column(TypeName = "datetime")]
    public DateTime CreatedDate { get; set; }

    public virtual ICollection<Release> AffectVersion { get; set; } = new List<Release>();

    public int AssignedTo { get; set; }

    [Column(TypeName = "datetime")]
    public DateTime AssignedDate { get; set; }

    [Column(TypeName = "date")]
    public DateTime? Deadline { get; set; }

    public int? ResolvedBy { get; set; }

    public virtual Solution? Resolution { get; set; }

    public virtual Release? ResolvedVersion { get; set; }

    [Column(TypeName = "datetime")]
    public DateTime? ResolvedDate { get; set; }

    public int? ClosedBy { get; set; }

    [Column(TypeName = "datetime")]
    public DateTime? ClosedDate { get; set; }

    public virtual Bug? DuplicateBug { get; set; }

    public virtual ICollection<Bug> LinkBugs { get; set; } = new List<Bug>();

    public int[] Cases { get; set; } = Array.Empty<int>();

    public int? LastEditedBy { get; set; }

    [Column(TypeName = "datetime")]
    public DateTime? LastEditedDate { get; set; }

    public int[] EditorFiles { get; set; } = Array.Empty<int>();

    public int[] Attachments { get; set; } = Array.Empty<int>();

    public int[] LogFiles { get; set; } = Array.Empty<int>();

    public virtual ICollection<OperationLog> OperationLogs { get; set; } = new List<OperationLog>();

    public bool Deleted { get; set; } = false;
}